#include "groupinfowindow.h"
#include "ui_groupinfowindow.h"

GroupInfoWindow::GroupInfoWindow(struct st_gData data,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GroupInfoWindow)
{
    ui->setupUi(this);

    m_gdata = data;
    ui->lab_gid->setText(QString::number(m_gdata.gid));
    ui->lab_gid_2->setText(QString::number(m_gdata.gid));
    ui->lab_gname->setText(m_gdata.gname);
    ui->lab_gname_2->setText(m_gdata.gname);
    ui->lab_introdution->setText(m_gdata.gintroduce);

    // 只保留关闭和最小化按钮
    this->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
    this->setWindowTitle("群资料");

    QString hname = QString("%1.png").arg(m_gdata.gid);
    QString iconUrl = QString("%1/%2").arg(PATH_IMG).arg(hname);
    ui->lab_icon->setPixmap(PixmapToRoundOpenCV(downLoadFromUrl(iconUrl)));

    //关闭释放内存 (若隐藏则什么操作也不做,效果和窗口关闭事件里写delete this一样)
    //setAttribute(Qt::WA_DeleteOnClose);

    // qss渲染
    setQssStyle(QString("../style/GroupInfoWindow.qss"),this);

    openNum = 1;


}

GroupInfoWindow::~GroupInfoWindow()
{
    delete ui;
}

void GroupInfoWindow::Show()
{
    if(openNum == 1){
        emit ui->widget_active->signal_attendStatus(NATIVE,10,3);
        emit ui->widget_man->signal_attendStatus(MAN,10,5);
        emit ui->widget_cz->signal_attendStatus(CITY,10,2);
        emit ui->widget_00->signal_attendStatus(ZERO,10,9);
    }
    show();
}

void GroupInfoWindow::on_btn_send_clicked()
{
    this->close();
    emit sig_ginfoWindowShow(m_gdata.gid);
}

